<?php

	namespace app\common\library;

	use OSS\Credentials\StaticCredentialsProvider;
	use OSS\OssClient;
	use think\Config;

	class AliyunOSS{
		public static function instance($options = []){
			$siteConfig = Config::get('site');
			$provider = new StaticCredentialsProvider($siteConfig['aliyun_key_id'],$siteConfig['aliyun_key_secret']);
			$bucket = $siteConfig['oss_bucket'];
			$config = [
				'provider' => $provider,
				'endpoint' => $siteConfig['oss_end_point'],
				'signatureVersion' => OssClient::OSS_SIGNATURE_VERSION_V4,
				'region'=> $siteConfig['oss_region'],
			];
			$ossClient = new OssClient(array_merge($config, $options));
			return $ossClient;
		}
	}